<template>
    <div style="height: 95%;width: 100%;display:flex;justify-content:center;padding-top: 20px">
        <!--弹框DIV 设置弹框的大小的地方-->
        <div style="background: #fff;width: 700px;height: 600px;box-shadow: #D3DCE6 0px 0px 20px;">
            <div style="height:520px;border: #1C84C6;margin-top: 25px" class="scrollbar">
                <div style="height: 30px;">
                    <!--标题-->
                    <span style="font-size: 18px;margin-left: 25px;">
                        编辑商机
                    </span>
                    <!--返回列表-->
                    <router-link style="margin-left: 530px;" :to="{path:'/zhuye/business'}">
                        <span>
                            <i slot="suffix" style="font-size: 30px;color: #D3DCE6" class="el-icon-close"></i>
                        </span>
                    </router-link>
                </div>
                <!--height:91%;表单在弹框显示多长-->
                <el-scrollbar style="height:91%;padding-top: 20px;">
                    <div class="shugan"></div>
                    <span style="margin-left: 10px;font-size: 14px;">基本信息</span>
                    <!--表单-->
                    <el-form style="margin-top:5px;margin-left: 40px;" ref="busfrom" size="mini" :model="busfrom" :rules="rules">
                        <el-row style="margin-top: 10px">
                            <el-col :span="11">
                                <el-form-item prop="busName" style="width:250px;">
                                    <label slot="label" style="font-size: 13px">商机名称：</label>
                                    <el-input v-if="clienflag!=0" :disabled="true" v-model="busfrom.busName"></el-input>
                                    <el-input v-if="clienflag==0" v-model="busfrom.busName"></el-input>

                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="margin-left: 20px;width:250px">
                                    <label slot="label" style="font-size: 13px">商机编号：</label>
                                    <el-input v-model="busfrom.busNo" :disabled="true"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="11">
                                <el-form-item prop="client.clientName"  style="width:250px">
                                    <label slot="label"  style="font-size: 13px">客户名称：</label>
                                    <el-popover
                                            style="width: 700px; height: 450px;"
                                            placement="right"
                                            trigger="click"
                                            v-model="kehu">
                                        <span style="font-size: 16px;">关联客户模块</span>
                                        <br/>
                                        <el-input @keyup.enter.native="initData" v-model="kehuinput" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                            <i slot="suffix" class="el-input__icon el-icon-search" @click="initData"></i>
                                        </el-input>
                                        <el-button type="primary" style="margin-left: 130px;">新 建</el-button>
                                        <el-table
                                                highlight-current-row
                                                border
                                                ref="kehulist"
                                                :data="kehulist">
                                            <el-table-column type="selection" width="50" align="center" property="clientId"></el-table-column>
                                            <el-table-column width="150" property="clientName" label="客户名称"></el-table-column>
                                            <el-table-column width="100" property="clientRank" label="级别"></el-table-column>
                                            <el-table-column width="150" property="clientMobile" label="手机号码"></el-table-column>
                                            <el-table-column width="200" property="clientSite" label="地址"></el-table-column>
                                        </el-table>
                                        <el-pagination
                                                style="margin-left: 350px;"
                                                layout="prev, pager, next"
                                                :page-size="clipagesize"
                                                :current-page.sync="clicurrentPage"
                                                :total="totalSize">
                                        </el-pagination>
                                        <div style="text-align: center;width: 100%" class="dialog-footer">
                                            <el-button type="primary" @click="xzkehu">保 存</el-button>
                                            <el-button type="primary" @click="kehu = false">取 消</el-button>
                                        </div>
                                        <el-input v-if="clienflag==0" v-model="busfrom.client.clientName" placeholder="+添加" slot="reference" :readonly='true' style="width: 250px;"></el-input>
                                    </el-popover>
                                    <el-input v-if="clienflag!=0" :disabled="true" v-model="busfrom.client.clientName" placeholder="+添加" :readonly='true' style="width: 250px;"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item prop="busPrimarycontact" style="margin-left: 20px;width:250px">
                                    <label slot="label" style="font-size: 13px">客户联系人：</label>
                                    <!--客户签约人-->
                                    <el-select style="width:250px" v-model="busfrom.busPrimarycontact" value-key="linkmanId" placeholder="请选择">
                                        <el-option
                                                v-for="item in linkmanoptions"
                                                :key="item.linkmanId"
                                                :label="item.linkmanName"
                                                :value="item">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="11">
                                <el-form-item style="width:250px">
                                    <label slot="label" style="font-size: 13px">预签单日期：</label>
                                    <el-date-picker
                                            v-model="busfrom.busWritten"
                                            align="right"
                                            type="date"
                                            style="width: 250px "
                                            placeholder="选择日期"
                                            format="yyyy 年 MM 月 dd 日"
                                            value-format="yyyy-MM-dd"
                                    >
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="margin-left: 20px;width:250px;">
                                    <label slot="label" style="font-size: 13px">预期金额：</label>
                                    <el-input v-model="busfrom.busMoney" @input="checkInput"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="11">
                                <el-form-item prop="busPeople" style="width:250px">
                                    <label slot="label" style="font-size: 13px">负责人：</label>
                                    <el-input v-model="busfrom.busPeople" :disabled="true">
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item style="margin-left: 20px;width:250px">
                                    <label slot="label" style="font-size: 13px">可能性：</label>

                                    <el-input v-model="busfrom.busPossibility" :disabled="true"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="11">
                                <el-form-item style="width:250px">
                                    <label slot="label" style="font-size: 13px">阶段：</label>
                                    <el-select style="width:250px"  :disabled="true" v-model="busfrom.phase" value-key="phaseId" placeholder="请选择">
                                        <el-option
                                                v-for="phase in phaseoptions"
                                                :key="phase.phaseId"
                                                :label="phase.phaseName"
                                                :value="phase">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <div style="margin-top: 10px">
                        <span style="margin-left: -10px;font-size: 13px">产品</span>
                        <!--添加产品按钮-->
                        <el-popover
                                    style="width: 700px; height: 450px;"
                                    placement="left"
                                    trigger="click"
                                    v-model="chanp"
                                    @selection-change="handleSelectionChange">
                                <span style="font-size: 16px;">关联产品模块</span>
                                <br/>
                                <el-input @keyup.enter.native="initProData" v-model="chanpinput" size="mini" style="width: 210px; margin-left: 230px; margin-bottom: 10px;">
                                    <i slot="suffix" class="el-input__icon el-icon-search" @click="initProData"></i>
                                </el-input>
                                <el-button type="primary" size="mini" style="margin-left: 130px;">新 建</el-button>

                                <el-table
                                    :data="proList"
                                    ref="multipleSelection"
                                    highlight-current-row
                                    border>
                                <el-table-column
                                        prop="prodetailId"
                                        type="selection"
                                        width="50"
                                        align="center">
                                </el-table-column>
                                <el-table-column
                                        prop="productId.productName"
                                        label="产品名称"
                                        align="center">
                                </el-table-column>
                                <el-table-column
                                        label="产品规格"
                                        align="center">
                                    <template slot-scope="s">
                                        <span v-for="pro in s.row.qmodeldetails" :key="pro.prodetailId">
                                            {{pro.modetContent}}
                                        </span>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="prodetaiJpri"
                                        label="进价（元）"
                                        align="center">
                                </el-table-column>
                                <el-table-column
                                        prop="prodetailSpri"
                                        label="售价（元）"
                                        align="center">
                                </el-table-column>
                                <el-table-column
                                        prop="prodetailKcnum"
                                        label="库存数量（件）"
                                        align="center">
                                </el-table-column>
                            </el-table>
                                <el-pagination
                                        style="margin-left: 350px;"
                                        @current-change="handleCurrentChange"
                                        layout="prev, pager, next"
                                        :current-page="currentPage"
                                        :page-size="pagesize"
                                        :total="pagetotal">
                                </el-pagination>
                                <div style="text-align: center;width: 100%" class="dialog-footer">
                                    <el-button type="primary" @click="trueaddpro">保 存</el-button>
                                    <el-button type="primary" @click="chanp = false">取 消</el-button>
                                </div>
                            <el-button slot="reference" size="mini" :readonly='true'
                                       style="margin-left:510px;" type="primary">添加商品</el-button>
                        </el-popover>

                        <el-table
                                    :data="dbuspros"
                                    style="width: 88%;margin-left: 10px;font-size:13px">
                                <el-table-column
                                        prop="prodetailId"
                                        type="selection"
                                        width="50"
                                        align="center">
                                </el-table-column>
                                <el-table-column
                                        align="center"
                                        prop="productId.productName"
                                        label="产品名称"
                                        width="90">
                                </el-table-column>
                                <el-table-column
                                        align="center"
                                        label="产品规格"
                                        width="150">
                                    <template slot-scope="s">
                                        <span v-for="pro in s.row.qmodeldetails" :key="pro.prodetailId">
                                            {{pro.modetContent}}
                                        </span>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        align="center"
                                        prop="prodetaiJpri"
                                        label="进价"
                                        width="90">
                                </el-table-column>
                                <el-table-column
                                        align="center"
                                        label="售价"
                                        width="90">
                                    <template slot-scope="d">
                                        <span>{{d.row.prodetailSpri}}</span>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        align="center"
                                        label="数量"
                                        width="150">
                                    <template slot-scope="d">
                                        <el-input-number @change="discount()" size="mini" :min="1" :max="10" v-model="d.row.busproNum"></el-input-number>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        align="center"
                                        label="折扣（%）"
                                        width="90">
                                    <template slot-scope="d">
                                        <el-input @change="discount()" oninput="if(value>100){value=100}else{value=value.replace(/[^\d]/g,'')}if(value.indexOf(0)==0){value=0}"  size="mini" v-model="d.row.busproDeiscount" ></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        align="center"
                                        prop="busproTotal"
                                        label="合计"
                                        width="90">
                                    <template slot-scope="d">
                                        <span>{{d.row.busproTotal}}</span>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        label="操作"
                                        width="90">
                                    <template slot-scope="s">
                                        <!--如果是三个标签，后两个标签padding-left: 10px;-->
                                        <i @click="truedetpro(s.row)" style="font-size:18px;padding-left: 20px;color: #409EFF" class="el-icon-delete"></i>
                                    </template>
                                </el-table-column>
                            </el-table>
                        <div style="margin-left:440px;font-size: 12px;margin-top: 10px;">
                            <span>总金额：</span>
                            {{aggregate}}
                            <span>元</span>

                        </div>
                            <div style="height: 10px"></div>
                    </div>
                    </el-form>
                </el-scrollbar>
                <!--确定按钮 设置了固定定位-->
                <div style="text-align: center;width: 80%;position: absolute;top:635px;left:230px;" class="dialog-footer">
                    <!--返回列表-->
                    <router-link :to="{path:'/zhuye/heton'}">
                        <el-button @click="jilutankuan = false">取 消</el-button>
                    </router-link>
                    &nbsp;&nbsp;
                    <el-button type="primary" @click="addbusiness('busfrom')">确 定</el-button>
                </div>


            </div>
        </div>
    </div>
</template>

<script>
    import Crypto  from '../router/secret'

    export default {
        name: "Daddbusniess",
        data() {
            return {

                /*产品分页数据*/
                pagesize:4,//页大小
                currentPage:1,//当前页
                pagetotal:0,//总页数

                multipleSelection:[],//产品选中值

                proList:[],//产品列表

                chanp:false,
                chanpinput:'',

                /*标志是新增还是修该*/
                clienflag:0,


                clipagesize:4,//客户分页页大小
                clicurrentPage:1,//客户当前页码，默认为1
                totalSize:0,//客户总记录数
                kehuinput:'',//客户搜索框
                kehulist:[],//客户列表

                /*确认删除产品*/
                centerDialogVisible:false,


                /*产品弹框*/
                jilutankuan:false,

                /*选择产品场景*/
                selectaproduct:'',
                /*搜索产品名称*/
                searchtheproduct:'',

                /*选择客户场景*/
                selectacustomer:'',
                /*搜索客户名称*/
                searchthecustomer:'',
                /*产品总金额*/
                aggregate:0,

                /*商机表单*/
                busfrom: {
                    /*商机基本信息数据*/
                    busId:0,/*商机编号*/
                    busName: '',/*商机名称*/
                    busSettime:'',/*商机建立时间*/
                    client: {
                    /*客户名称*/
                        clientId:0,
                        clientName:'',
                    },
                    busPrimarycontact: {
                        linkmanId:0,
                        linkmanName:'',
                    },/*客户联系人*/
                    busPeople: '',/*负责人*/
                    busNo:'',/*商机编号*/
                    /*预期数据*/
                    busWritten:'',/*预期签单日期*/
                    busPossibility:'20%',/*可能行*/
                    busMoney:0,/*预期金额*/
                    /*阶段*/
                    phase:{
                        phaseId:0,
                        phaseName:'',
                    }

                },
                /*产品表格*/
                dbuspros:[],

                phaseoptions:[],//初始化阶段数据
                linkmanoptions:[],//初始化联系人数据

                rules: {
                    busName: [
                        {required: true, message: '请输入商机名称', trigger: 'blur'},
                        {min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur'}
                    ],
                    'client.clientName': [
                        {required: true, message: '请选择客户', trigger: ['blur','change']}
                    ],
                    busPrimarycontact: [
                        {type:'object',required: true, message: '请选择客户联系人', trigger:  ['blur','change']}
                    ],
                    phase: [
                        {required: true, message: '请选择阶段', trigger: 'change'}
                    ],

                },

                kehu: false,

            };

        },
        methods: {

            /*验证输入的预期金额*/
            checkInput() {
                this.busfrom.busMoney = this.dealInputVal(this.busfrom.busMoney);
            },
            dealInputVal(value) {
                value = value.replace(/^0*(0\.|[1-9])/, "$1");
                value = value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
                value = value.replace(/^\./g, ""); //验证第一个字符是数字而不是字符
                value = value.replace(/\.{1,}/g, "."); //只保留第一个.清除多余的
                value = value
                    .replace(".", "$#$")
                    .replace(/\./g, "")
                    .replace("$#$", ".");
               /* value = value.replace(/^(\-)*(\d*)\.(\d\d).*$/, "$1$2.$3"); //只能输入两个小数*/
                value =
                    value.indexOf(".") > 0
                        ? value.split(".")[0].substring(0, 10) + "." + value.split(".")[1]
                        : value.substring(0, 10);
                return value;
            },


            /*初始化阶段列表*/
            inphase(){
                this.$axios.post("http://localhost:8088/business/phase").then(v => {
                    this.print(v.data);
                    this.phaseoptions = v.data;
                }).catch(() => {

                })
            },

            /*新建时默认选择初级沟通*/
            addinphase(){
                this.$axios.post("http://localhost:8088/business/phase").then(v => {
                    this.print(v.data);
                    this.phaseoptions = v.data;
                    this.busfrom.phase=v.data[0];
                    this.busfrom.busPossibility=v.data[0].phasePoss;
                }).catch(() => {

                })
            },

            /*初始化商机负责人*/
            initbuspeople() {

                /*取session中的负责人*/
                var storage = window.localStorage;
                var user = storage.getItem('user');
                /*赋值*/
                this.busfrom.busPeople = JSON.parse(user).empName;

            },
            /*初始化商机编号*/
            initbusNo() {
                var date = new Date();
                var year = date.getFullYear();
                var month = date.getMonth() + 1;
                var day = date.getDate();
                if (month < 10) {
                    month = "0" + month;
                }
                if (day < 10) {
                    day = "0" + day;
                }
                //使用年月日作为中间数
                var busnosj = year + month + day;

                //使用时间戳作为最后五位随机数
                var a = date.getTime() + "";
                var b = a.substring(8, 13);

                //最后编号
                var busno = "M_" + busnosj + "_" + b;
                this.busfrom.busNo = busno;
            },
            /*客户查询方法*/
            initData(){
                this.$axios.post("http://localhost:8088/business/allclientbyemp",this.qs.stringify(
                    {search:this.kehuinput, currentpage:this.clicurrentPage, pagesize:this.clipagesize,}))
                    .then(v=>{
                        window.console.log(v.data.rows);
                        this.kehulist = v.data.rows;
                        this.totalSize = v.data.total;
                    }).catch()
            },
            /*新增or修改商机方法*/
            addbusiness(formName) {

                if(this.busfrom.busId!=0){
                    this.addbusinfo();
                }else{
                    this.$refs[formName].validate(valid => {
                        this.print(valid);
                        if (valid) {
                            this.addbusinfo();
                        }else{
                            this.$message({
                                message: '验证不通过！',
                                type: 'warning'
                            });
                            return false;
                        }

                    });
                }
            },

            addbusinfo(){
                var busform=JSON.stringify({busfrom:this.busfrom,dbuspros:this.dbuspros})
                this.$axios.post("http://localhost:8088/business/addbusiness",this.qs.stringify({busfrom:busform})).then((v) => {
                    this.print(v.data);
                    if(v.data){
                        this.linkmanoptions=[];
                        if (this.busfrom.busId==0) {
                            this.$message({
                                type: 'success',
                                message: '新增成功!'
                            });
                            this.$router.push({
                                path: "/business",
                            });
                        }
                        if (this.busfrom.busId!=0) {
                            this.$message({
                                type: 'success',
                                message: '修改成功!'
                            });
                            this.$router.push({
                                path: "/business",
                            });

                        }
                    }else{
                        this.$message({
                            message: '该商机名称已存在！',
                            type: 'warning'
                        });
                    }

                }).catch(() => {

                });
            },

            /*初始化产品*/
            initProData(){
                window.console.log();
                this.$axios.post("http://localhost:8088/business/selectprodetails",
                this.qs.stringify({
                    currentpage:this.currentPage,pagesize:this.pagesize,
                    proName:this.chanpinput
                }))
                    .then(v=>{
                        this.proList = v.data.rows;
                        this.pagetotal=v.data.total;
                    })
                    .catch()
            },

            /*当前页方法*/
            handleCurrentChange(val) {
                window.console.log(`当前页: ${val}`);
                this.currentPage=val;
                this.initProData();
            },


            /*选择客户*/
            xzkehu() {
                this.$refs.kehulist.selection.forEach((pro)=>{
                    this.busfrom.client=pro;
                });
                this.viewdata(this.busfrom.client.clientId);
                this.kehu=false;
                this.kehuinput='';
            },

            /*客户选择完后绑定联系人*/
            viewdata(a){
                /*客户绑定首要联系人*/
                this.$axios.post("http://localhost:8088/business/selectmainlinkman",this.qs.stringify({
                    search:a
                }))
                .then(v=>{
                    this.busfrom.busPrimarycontact={
                        linkmanId:0,
                        linkmanName:'',
                    };
                    this.linkmanoptions = v.data;
                    v.data.forEach((item) => {
                        if(item.keyPolicymaker==1){
                            this.busfrom.busPrimarycontact = item;
                        }
                    })

                }).catch(()=>{

                })
            },



            /*选择产品*/
            trueaddpro(){
                var flag = false;
                this.$refs.multipleSelection.selection.forEach((pro,i)=>{
                    flag = false;
                    if(this.dbuspros.length !=0){
                        this.dbuspros.forEach((list)=>{

                            if(pro.prodetailId==list.prodetailId){
                                this.$confirm('此产品已经存在，如需添加请直接修改数量!', '提示', {
                                    confirmButtonText: '确定',
                                    cancelButtonText: '取消',
                                    type: 'warning',
                                    center: true
                                }).then(() => {
                                }).catch(() => {
                                });
                                flag=true
                            }

                        })

                    }
                    if(flag==false){
                        //不存在产品,则可以添加
                        console.log("不存在产品1")
                        this.addList(pro,i);
                    }


                });

                this.multipleSelection=[];
                this.$refs.multipleSelection.clearSelection();
                this.chanp=false;

                this.discount();

            },

            //复选框选中的
            handleSelectionChange(val) {
                this.multipleSelection = val;//  this.multipleTable 选中的值

            },

            //添加的产品的方法
            addList(pro,i){
                this.$set(pro,'busproNum',1);//数量
                this.$set(pro,'busproTotal',pro.prodetailSpri);//小计
                this.$set(pro,'busproDeiscount',100);//折扣
                this.dbuspros.splice(i,0,pro);
            },



            /*商机修改页面返回*/
            detailsdata(){
                this.clienflag=1;
                var busId = Crypto.get(unescape(this.$route.query.busId));
                this.$axios.post("http://localhost:8088/business/selectBybusId",this.qs.stringify({busId:busId}))
                    .then((v)=>{
                        this.busfrom=v.data;

                        this.editprodata(busId);

                        this.$axios.post("http://localhost:8088/business/selectmainlinkman",this.qs.stringify({
                            search:this.busfrom.client.clientId
                        })).then(k=>{
                                this.linkmanoptions = k.data;
                                k.data.forEach((item) => {
                                    if(item.linkmanId==this.busfrom.busPrimarycontact.linkmanId){
                                        this.busfrom.busPrimarycontact = item;
                                    }

                                })

                            }).catch(()=>{

                        });
                        this.discount();


                    }).catch(()=>{

                })
            },


            /*查询的产品方法*/
            editprodata(busId){
                this.$axios.post("http://localhost:8088/buspro/selectbuspro",this.qs.stringify({busId:busId}))
                    .then((v)=>{
                        this.dbuspros=v.data;
                        this.discount();
                    }).catch(()=>{

                })
            },

            /*确认删除*/
            truedetpro(row){
                this.centerDialogVisible=false;
                this.dbuspros.forEach((pur,i)=>{
                    if(pur.prodetailId==row.prodetailId){
                        this.dbuspros.splice(i,1);
                    }
                })
                this.discount();

            },

            //计算每行折扣金额
            discount(){
                var count = 0;
                this.dbuspros.forEach((v)=>{
                    if(v.busproDeiscount==''){
                        v.busproDeiscount=100;
                    }
                    var lir = v.prodetailSpri*(v.busproDeiscount/100);
                    if(lir<v.prodetaiJpri){
                        v.busproDeiscount=100;
                        this.$message({
                            message: '折扣太低，亏本了！',
                            type: 'warning'
                        });
                    }

                    v.busproTotal=this.numFilter(v.prodetailSpri*(parseFloat(v.busproDeiscount)/100)*v.busproNum);
                    count=this.numFilter(parseFloat(count)+parseFloat(v.busproTotal));
                })
                this.aggregate = count;
            },

            /*去掉小数点*/
            numFilter (value) {
                let realVal = ''
                if (!isNaN(value) && value!== '') {
                    // 截取当前数据到小数点后两位
                    realVal = parseFloat(value).toFixed(2)
                } else {
                    realVal = '--'
                }
                return realVal
            },

        },

        beforeRouteEnter(to, from, next) {
            console.log("****************Test2*********Enter*********");
            console.log(this, 'beforeRouteEnter'); // undefined
            console.log('to', to);
            console.log('from', from);
            console.log('next', next);

            next(vm => {

                if(from.path!='/business'){
                    vm.initbusNo();
                    vm.initbuspeople();
                }

                //因为当钩子执行前，组件实例还没被创建
                // vm 就是当前组件的实例相当于上面的 this，所以在 next 方法里你就可以把 vm 当 this 来用了。
                console.log(vm);//当前组件的实例
            });
        },

        created: function (){
            this.initData();
            this.clienflag=0;
            this.initProData();
            this.initbusNo();
            this.initbuspeople();

            if(this.$route.query.busId){
                this.detailsdata();
                this.inphase();
            }else{
                this.addinphase();
            }


        },
        watch:{
            $route(to,from){
                window.console.log("to"+to);
                window.console.log("from"+from.path);

            },


            'busfrom.busMoney':function (newVal,oldVal) {

                // 保留两位小数
                if(newVal){
                    newVal = newVal.toString();
                    var pointIndex =  newVal.indexOf('.');
                    if(pointIndex>0 && (newVal.length - pointIndex)>3){
                        this.busfrom.busMoney = oldVal;
                        return ;
                    }
                }

            }

        },
        filters: {
            numFilter (value) {
                let realVal = ''
                if (!isNaN(value) && value!== '') {
                    // 截取当前数据到小数点后两位
                    realVal = parseFloat(value).toFixed(2)
                } else {
                    realVal = '--'
                }
                return realVal
            }
        }
    }

</script>

<style scoped>

    .el-tag + .el-tag {
        margin-left: 10px;
        margin-top: 5px;
    }
    .button-new-tag {
        margin-left: 10px;
        height: 32px;
        line-height: 30px;
        padding-top: 0;
        padding-bottom: 0;
    }
    .input-new-tag {
        width: 90px;
        margin-left: 10px;
        vertical-align: bottom;
    }
    .shugan{
        border-left-color: rgb(70, 205, 207);
        border-left-width: 1.8px;
        height: 10px;
        border-left-style: solid;
        display: inline;
        font-size: 13px;
        margin-left: 25px;
    }

    /* /deep/ .el-scrollbar__wrap {
         overflow: scroll;
         height: 100%;
     }*/

    [data-v-3c674d34] .el-scrollbar__wrap{
        width: 100%;
    }
</style>